package com.open4cn.simulator.answer.datacolor;

import com.open4cn.simulator.core.answer.AbstractAction;
import com.open4cn.simulator.core.ext.DataColorStatus;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description
 * @Email yinxiaopeng@zj.tech
 * @date 2022-05-05 17:01
 */
public class GreenboardAction extends AbstractAction {

    public GreenboardAction() {
        super(null);
    }

    public GreenboardAction(AbstractAction action) {
        super(action);
    }

    @Override
    public void action(Object... params) {
        DataColorStatus dataColorStatus = (DataColorStatus) params[0];
        dataColorStatus.triggerGreenboard();
        dataColorStatus.changeCorrectionStage(DataColorStatus.CorrectionStageEnum.GREEN_BOARD);
        if (dataColorStatus.hasGreenStandard() && dataColorStatus.greenboardFrequency() == 1) {
            dataColorStatus.stopCorrection();
        }
        if (!dataColorStatus.hasGreenStandard() && dataColorStatus.greenboardFrequency() == 2) {
            dataColorStatus.stopCorrection();
        }
        if (hasNext()) {
            action.action(params);
        }
    }
}
